import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {TopUpVO, TopUpForm, TopUpQuery} from '@/api/pay/topUp/types';

/**
 * 查询系统充值订单列表
 * @param query
 * @returns {*}
 */

export const listTopUp = (query?: TopUpQuery): AxiosPromise<TopUpVO[]> => {
  return request({
    url: '/topUp/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询系统充值订单详细
 * @param topUpId
 */
export const getTopUp = (topUpId: string | number): AxiosPromise<TopUpVO> => {
  return request({
    url: '/topUp/' + topUpId,
    method: 'get'
  });
};

/**
 * 新增系统充值订单
 * @param data
 */
export const addTopUp = (data: TopUpForm) => {
  return request({
    url: '/topUp',
    method: 'post',
    data: data
  });
};

/**
 * 修改系统充值订单
 * @param data
 */
export const updateTopUp = (data: TopUpForm) => {
  return request({
    url: '/topUp',
    method: 'put',
    data: data
  });
};

/**
 * 删除系统充值订单
 * @param topUpId
 */
export const delTopUp = (topUpId: string | number | Array<string | number>) => {
  return request({
    url: '/topUp/' + topUpId,
    method: 'delete'
  });
};

/**
 * 退款
 * @param topUpId
 */
export const refund = (topUpId: string | number) => {
  return request({
    url: '/pay/refund',
    method: 'post',
    params: {topUpId}
  });
};
